<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/pages/system/base.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>科研工作量详情管理</title>
</head>
<body>
	<table id="dg" class="" title="列表" style="width: 700px; height: 300px">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true"></th>
				<th data-options="field:'teacherinfo.gonghao',width:40"
					formatter="getGonghao">工号</th>
				<th data-options="field:'teacherinfo.realname',width:40"
					formatter="getRealName">姓名</th>
				<th data-options="field:'swname',width:240">科研名称</th>
				<th data-options="field:'scienceworktype.swtype',width:80"
					formatter="getSwtype">科研类型</th>
				<th data-options="field:'scienceworkweight.swweight',width:80"
					formatter="getSwweight">权重类型</th>
				<th data-options="field:'scienceworkweight.weight',width:40"
					formatter="getWeight">权重值</th>
				<th data-options="field:'score',width:40">分值</th>
			</tr>
		</thead>
	</table>

	<div id="toolbar">
		<a href="#" class="easyui-linkbutton remove"
			iconCls="icon-remove" onclick="del()" plain="true">删除</a>
			<a href="#" class="easyui-linkbutton back"
			iconCls="icon-back" onclick="exportExcel()" plain="true">excel导出</a>
		<div>
			工号: <input class="easyui-textbox" id="paramName"> <a href="#"
				class="easyui-linkbutton" onclick="doSearch()" iconCls="icon-search">查找</a>
			<a href="#" class="easyui-linkbutton" onclick="doReset()"
				iconCls="icon-redo">重置</a>

		</div>
	</div>

	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton  save" onclick="save()"
			iconCls="icon-ok">保存</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#dlg').dialog('close')" iconCls="icon-cancel">取消</a>
	</div>

	<div id="teacherdg" class="easyui-dialog" title="数据"
		style="width: 350px; height: 450px; top: 80px;"
		data-options="modal:true" closed="true" buttons="#dlgTeacher-buttons">
		<table id="teachertable" class="" title="列表"
			style="width: 700px; height: 300px">
			<thead>
				<tr>
					<th data-options="field:'teachernum',width:80">工号</th>
					<th data-options="field:'teachername',width:80">教师姓名</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="teachertoolbar">
		<div>
			教师工号: <input class="easyui-textbox" id="paramTeacherName"> <br />
			<a href="#" class="easyui-linkbutton" onclick="teacherSearch()"
				iconCls="icon-search">查找</a> <a href="#" class="easyui-linkbutton"
				onclick="teacherReset()" iconCls="icon-redo">重置</a>
		</div>
	</div>
	<div id="dlgTeacher-buttons">
		<a href="#" class="easyui-linkbutton  save"
			onclick="afterTeacherSelect('teachertable','teacherdg','teacherid','teachername')"
			iconCls="icon-ok">确定</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#teacherdg').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>

	<div id="studentdg" class="easyui-dialog" title="数据"
		style="width: 350px; height: 450px; top: 80px;"
		data-options="modal:true" closed="true" buttons="#dlgClass-buttons">
		<table id="studenttable" class="" title="列表"
			style="width: 700px; height: 300px">
			<thead>
				<tr>
					<th data-options="field:'studentnum',width:80">学号</th>
					<th data-options="field:'name',width:80">学生姓名</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="studenttoolbar">
		<div>
			学生姓名: <input class="easyui-textbox" id="paramStudentName"> <br />
			<a href="#" class="easyui-linkbutton" onclick="studentSearch()"
				iconCls="icon-search">查找</a> <a href="#" class="easyui-linkbutton"
				onclick="studentReset()" iconCls="icon-redo">重置</a>
		</div>
	</div>
	<div id="dlgClass-buttons">
		<a href="#" class="easyui-linkbutton  save"
			onclick="afterSelect('studenttable','studentdg','studentid','name')"
			iconCls="icon-ok">确定</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#studentdg').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>

	<div id="dlg-upload" class="easyui-dialog" title="excel导入"
		data-options="modal:true"
		style="width: 350px; height: 130px; top: 80px;" closed="true"
		buttons="#upload-buttons">
		<form method="post" id="fm-upload" enctype="multipart/form-data">
			<table>
				<tr>
					<td>上传excel:</td>
					<td><input class="easyui-filebox" style="width: 240px"
						accept="application/vnd.ms-excel" id="scoreExcel"
						name="scoreExcel" data-options="prompt:'请选择文件...'"></input></td>
				</tr>
			</table>
		</form>
	</div>

	<div id="upload-buttons">
		<a href="#" class="easyui-linkbutton  save" onclick="uploadExcel()"
			iconCls="icon-ok">上传</a> <a href="#" class="easyui-linkbutton cancel"
			onclick="javascript:$('#dlg-upload').dialog('close')"
			iconCls="icon-cancel">取消</a>
	</div>
	<script type="text/javascript">
		$(function() {
			loadDataGrid();
		});
		function loadDataGrid(queryConditon) {
			$('#dg').datagrid({
				title : '成绩信息',
				iconCls : 'icon-ok',
				pageSize : 10,
	            pageList : [ 10, 15, 20 ],
				nowrap : true,
				striped : true,
				collapsible : true,
				toolbar : "#toolbar",
				url : 'scienceWorkController.do?datagrid',
				loadMsg : '数据装载中......',
				singleSelect : false,
				fitColumns : true,
				checkOnSelect : true,
				selectOnCheck : true,
				fit : true,
				remoteSort : false,
				pagination : true,
				rownumbers : true,
				queryParams : queryConditon
			});
		}
		function upload() {
			$('#dlg-upload').dialog('open').dialog('setTitle', 'excel导入');
			$('#fm-upload').form('clear');
		}
		var url;

		function doSearch() {
			var queryCondition = {
				'gonghao' : $('#paramName').val()
			};
			loadDataGrid(queryCondition);
		}
		function doReset() {
			$('#paramName').textbox('setValue', '');
			loadDataGrid(null);
		}
		function del() {
			var rows = $('#dg').datagrid('getSelections');
			var ids = [];
			if (rows.length > 0) {
				$.messager.confirm('提示信息', '确定删除?', function(r) {
					if (r) {
						for (var i = 0; i < rows.length; i++) {
							ids.push(rows[i].id);
						}
						$.ajax({
							url : 'scienceWorkController.do?delete',
							type : 'post',
							data : {
								ids : ids.join(',')
							},
							cache : false,
							success : function(result) {
								if (result.success) {
									$('#dg').datagrid('reload');
									$.messager.show({
										title : '提示信息',
										msg : result.msg
									});
								} else {
									$.messager.show({
										title : '提示信息',
										msg : result.msg
									});
								}
							}
						});
					}
				});
			} else {
				$.messager.show({
					title : '提示信息',
					msg : '请至少选择一条数据后再进行删除'
				});
			}
		}

		function exportExcel() {
			window.location.href = "scienceWorkController.do?expordetaillExcel";
		}

		function getGonghao(value, row, index) {
			return row['teacherInfoVO']['gonghao'];
		}
		function getRealName(value, row, index) {
			return row['teacherInfoVO']['realname'];
		}
		function getSwtype(value, row, index) {
			return row['scienceworktype']['swtype'];
		}
		function getSwweight(value, row, index) {
			return row['scienceworkweight']['swweight'];
		}
		function getWeight(value, row, index) {
			return row['scienceworkweight']['weight'];
		}
	</script>

</body>
</html>